home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12949 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  62 lines

  1. Newsgroups: comp.lang.c
  2. Path: news.inap.net!news1!ind-004-236-188
  3. From: dlmiller@iquest.net (Doug Miller)
  4. Subject: Re: help with strcmp
  5. X-Nntp-Posting-Host: ind-004-236-188.iquest.net
  6. Message-ID: <DpAI6o.2Cq@iquest.net>
  7. Sender: news@iquest.net (News Admin)
  8. Organization: IQuest Network Services
  9. X-Newsreader: News Xpress Version 1.0 Beta #2.1
  10. References: <4jpiek$lp6@blaze.cs.jhu.edu>
  11. Date: Wed, 3 Apr 1996 14:15:58 GMT
  12.  
  13. I don't notice any place where you have allocated storage for fp prior to attempting to transfer
  14. data to it.
  15.  
  16. lasher@hops.cs.jhu.edu (John E. Davis) wrote:
  17. >For some reason when I try to compare the strings in the following
  18. >snippet I consistently get a core dump (running on a UNIX machine running
  19. >Solaris).  Could anyone point out what may be going wrong?  I have run it
  20. >through the debugger and that was no help at all for me.  here is the
  21. >code snippet:
  22. >
  23. >#include <stdio.h>
  24. >#include <stdlib.h>
  25. >#include <string.h>
  26. >
  27. >void setup(FILE *);
  28. >
  29. >void main(int argc, char *argv[])
  30. >{
  31. >char         buf[20], data[40], *buff, *arg, *fp;
  32. >FILE         *handle, *dest;
  33. >int         n;
  34. >
  35. >handle = fopen(argv[1], "r");
  36. >if(dest = fopen( "dbuild.out", "w")) setup(dest);
  37. >
  38. >while(!feof(handle)) {
  39. >    n = 0;
  40. >    fp = fgets(data, 40, handle);
  41. >    if ( strcasecmp(fp, "<action>\n") == 0)  /* the coredump is here */
  42. >        parseAction(handle, dest);
  43. >    else if ( strcasecmp(fp, "<control>\n") == 0)
  44. >        parseControl(handle, dest);
  45. >    else if ( strcasecmp(fp, "<general>\n") == 0)
  46. >        parseGeneral(handle, dest);
  47. >    printf("%s", data);
  48. >     }
  49. >fclose(dest);
  50. >
  51. >}
  52. >
  53. >
  54. >--
  55. >John Davis
  56. >lasher@hops.cs.jhu.edu
  57. >http://hops.cs.jhu.edu/~lasher
  58. >
  59. >UNIX is a very user-friendly operating system
  60. > it's just picky about who it's friends with.
  61.  
  62.